package org.dinner.order.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@NamedQueries({
	@NamedQuery(name = "Dish.list", query = "from Dish"),
	@NamedQuery(name = "Dish.getByName", query = "from Dish d where d.name=:name"),
	@NamedQuery(name = "Dish.listByType", query = "select d from Dish d join d.type as t with t.id=:typeId") })
@Table(name = "DISHES")
public class Dish {
	
	@Id
	@GeneratedValue
	private int id;
	
	@Column(nullable = false, unique = true)
	private String name;
	
	@ManyToOne
	@JoinColumn(name="type_id", nullable=false)
	private DishType type;
	
	private double price;
	
	@Column(nullable=false)
	private boolean complex;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public DishType getType() {
		return type;
	}
	public void setType(DishType type) {
		this.type = type;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public boolean isComplex() {
		return complex;
	}
	public void setComplex(boolean complex) {
		this.complex = complex;
	}
	
	

}
